<template>
	<view class="content">
		<view class="me-userInfo">
			<view class="userInfo-top">
				<view class="user-info">
					<u-avatar :src="userInfo.head_img" size='55'></u-avatar>
					<view class="title flex">
						{{ userInfo.nickname}}
						<view class="" style="margin-left: 20px;">
							<h5 class="" v-if="userInfo.is_register == 1" @click.stop="goRegister">
								<i>请注册~</i>
							</h5>
							<h5 class="" v-if="userInfo.is_register == 2">
								已注册
							</h5>
						</view>
					</view>
					
				</view>
				<view class="" >
					<u-image width="100px" height="100px" :src="userInfo.img"></u-image>
				</view>
				<view class="arrow"  @click='gotouserInfo'>
					<u-icon name="arrow-right" color="#fff" size="28"></u-icon>
				</view>
			</view>
		</view>
		
		<u-cell-group class='list'>
			<u-cell  v-for="(item,index) in list" :key='index' :icon="item.icon" :title="item.title" :isLink="true" size='large' :url='item.url' @click='kefu(item)'>
				<view
					slot="title"
					class="u-slot-title flex"
				>
					<text class="u-cell-text">{{ item.title}}</text>
					<u-badge style='margin-left: 10px;' v-if='item.title == "我的消息" && userInfo.message_num == 1' :isDot="true" type="error"></u-badge>
				</view>
			</u-cell>
		</u-cell-group>
		
		<!-- <u-popup :show="showkefu" mode="center"  @close="close" @open="open" :closeable='true'>
			<view>
				111
			</view>
		</u-popup> -->
		<u-modal :show="showkefu" title="联系客服" @confirm="callphone" confirmText='呼叫' :showCancelButton='true' @cancel="close">
			<view class="slot-content flex">
				<u-image width="21px" height="21px" src="../../static/icon_call.png"></u-image>
				<view class="phone">
					{{ phone }}
					
				</view>
			</view>
		</u-modal>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: 'Hello',
				src: '',
				userInfo: {},
				list: [
					{
						title: '我的消息',
						icon: '../../static/me_14.png',
						url: '/pages/message/message'
					},
					{
						title: '环保金账户',
						icon: '../../static/me_01.png',
						url: '/pages/jifen/jifen'
					},
					{
						title: '投递记录',
						icon: '../../static/me_02.png',
						url: '/pages/deliveryList/deliveryList'
					},
					{
						title: '家庭成员',
						icon: '../../static/me_03.png',
						url: '/pages/family/family'
					},
					{
						title: '人脸照片',
						icon: '../../static/face.png',
						url: '/pages/face/face'
					},
					{
						title: '反馈意见',
						icon: '../../static/me_04.png',
						url: '/pages/feedback/feedback'
					},
					{
						title: '联系客服',
						icon: '../../static/con_kf_black.png',
					},
				],
				showkefu: false,
				phone: ''
			}
		},
		onLoad() {
			this.getuserInfo()
			this.getPhone()
		},
		methods: {
			goRegister(){
				uni.reLaunch({
					url: '/pages/register/register?type=1'
				})
			},
			gotouserInfo(){
				uni.navigateTo({
					url: '/pages/userInfo/userInfo'
				})
			},
			getuserInfo(){
				var _this = this
				this.fq_get('wxsite/User/userImgv2', {}, (res) => {
					if(res.code == 1){
						_this.userInfo = res.data
					}
				})
				// uni.request({
				// 	url: 'http://www.yndzfl.cn/wxsite/User/userImgv2',
				// 	method: 'POST',
				// 	header:{
				// 		"Content-Type" : "application/x-www-form-urlencoded"
				// 	},
				// 	data: {
				// 		openid: uni.getStorageSync('OPENID')
				// 	},
				// 	success(res) {
				// 		console.log(res)
				// 		if(res.data.code == 1){
				// 			_this.userInfo = res.data.data
				// 		}else if(res.data.code == -1){
				// 			uni.reLaunch({
				// 				url: '/pages/home/home'
				// 			})
				// 		}
						
				// 	}
				// })
			},
			getPhone(){
				var _this = this
				this.fq_get('wxsite/User/system', {}, (res) => {
					if(res.code == 1){
						_this.phone = res.data.phone
					}
				})
				// uni.request({
				// 	url: 'http://www.yndzfl.cn/wxsite/User/system',
				// 	method: 'POST',
				// 	header:{
				// 		"Content-Type" : "application/x-www-form-urlencoded"
				// 	},
				// 	data: {
				// 		openid: uni.getStorageSync('OPENID')
				// 	},
				// 	success(res) {
				// 		console.log(res)
				// 		if(res.data.code == 1){
				// 			_this.phone = res.data.data.phone
				// 		}
						
				// 	}
				// })
			},
			kefu(item){
				if(item.title == '联系客服'){
					this.showkefu = true
				}
				
			},
			close(){
				this.showkefu = false
				
			},
			callphone(){
				this.showkefu = false
				uni.makePhoneCall({
					phoneNumber: this.phone //仅为示例
				});
			}
		}
	}
</script>

<style scoped>
	.content{
		background: #F6f6f6;
		min-height: 100vh;
	}
	.me-userInfo{
		margin: .24rem 0;
		background: #fff;
		border-radius: .2rem;
	}
	.userInfo-top{
		background: url('../../static/me_bg.png') no-repeat;
		background-size: 100% 100%;
		height: 130px;
		width: 100%;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
	.user-info{
		width: 50%;
		/* text-align: center; */
		display: flex;
		flex-direction: column;
		align-items: center;
	}
	.user-info .title{
		font-size: 14px;
		color: #333;
		margin-top: 5px;
	}
	.arrow{
		padding: 10px;
	}
	.list{
		margin-top: 10px;
		background-color: #fff;
	}
	.list /deep/.u-cell__left-icon-wrap{
		margin-right: 10px;
	}
	.flex{
		display: flex;
		align-items: center;
	}
	.phone{
		margin-left: 10px;
	}
</style>
